<template>
  <div class="b-step-wrapper">
    <div
        v-for="(item, index) in stepsList"
        :key="index" 
        :class="[
            'b-step-item',
            current === index
            ? 'steps_status_process'
            : current > index
            ? 'steps_status_finish'
            : 'steps_status_wait',
        ]"
    >   
        <div class="steps_tail"><i></i></div>
        <div class="steps_head" @click="handleChangeCurrent(index)">
            <div class="steps_head_inner">
                <span v-if="current > index && isChangeIcon">
                    <i class="iconfont icon-duigou"></i>
                </span>
                <span v-else>{{ index + 1 }}</span>
            </div>
            <div class="steps_content">
                <div class="title">{{ item.title }}</div>
                <div class="time">{{ item.content  }}</div>
            </div>
        </div>
    </div>
  </div>
</template>
  
  <script>
export default {
  name: "steps",
  props: {
    // 当前步骤
    current: {
      type: Number,
      default: function() {
        return 0;
      }
    },
    stepsList: {
      type: Array,
      default: function() {
        return [];
      }
    },
    // 步骤条的方向，可选值为horizontal（水平）或vertical（垂直）
    direction: {
      type: String,
      default: function() {
        return "horizontal";
      }
    },
    // 是否改变icon
    isChangeIcon: {
      type: Boolean,
      defalut: () => true
    },
    isFinished: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      imList: [
        "https://picsum.photos/id/237/200/300",
        "https://picsum.photos/id/237/200/300"
      ]
    };
  },
  methods: {
    // a标签方式下载文件
    funDownload(url) {
      // 创建隐藏的可下载链接
      let eleLink = document.createElement("a");
      // 使用阿里云oss会造成download失效
      // eleLink.download = fileName;
      eleLink.setAttribute("download", "文件");
      eleLink.setAttribute("href", url);
      eleLink.style.display = "none";
      // 触发点击
      document.body.appendChild(eleLink);
      eleLink.click();
      // 然后移除
      document.body.removeChild(eleLink);
    },
    // 按钮集点击事件
    btnFun(val) {
      val.btnClick && val.btnClick(val);
    },
    // 切换当前所选项
    handleChangeCurrent(index) {
      console.log(index);
      if (!this.isChangeIcon) {
        this.$emit("change", index);
      }
    }
  },
  computed: {
    noLabelContent() {
      return function(arr) {
        return arr.filter(item => item.label === "");
      };
    },
    labelContent() {
      return function(arr) {
        return arr.filter(item => item.label !== "");
      };
    }
  }
};
</script>
  
  <style lang="scss" scoped>
@import "@/styles/_themes.scss";
@import "@/styles/_handle.scss";
.b-step-wrapper {
  display: flex;
  width: 100%;
  font-size: 0;
  line-height: 1.5;
  padding: 16px 244px 84px;
  margin-bottom: 24px;
}
.b-step-item {
  display: inline-block;
  position: relative;
  vertical-align: top;
  flex: 1;
  &:last-of-type{
    .steps_tail {
        display: none;
    }
  }
}
.b-step-item:last-of-type{
    width: 44px !important;
    flex: none;
}
.steps_tail {
  position: absolute;
  left: 66px;
  right: 22px;
  top: 50%;
}
.steps_tail > i {
  display: inline-block;
  width: 100%;
  height: 1px;
  vertical-align: top;
  background: #e8eaec;
  border-radius: 1px;
  position: relative;
  &:after {
    content: "";
    width: 0;
    height: 100%;
    background: #e8eaec;
    opacity: 0;
    position: absolute;
    top: 0;
  }
}
.steps_status_process{
    .steps_tail{
        > i {
            @include dotted_style("colorTheme");
        }
    }
    .steps_content{
        .title{
            @include font_color("colorTheme");
        }
    }
}
.steps_head {
  background: #fff;
  position: relative;
  display: inline-block;
  vertical-align: top;
  cursor: pointer;
  & .steps_head_inner {
    display: block;
    width: 44px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    border: 1.8px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    color: rgba(0, 0, 0, 0.25);;
    font-size: 16px;
    transition: background-color 0.2s ease-in-out;
    i{
        font-size: 24px;
    }
  }
}
.steps_main {
  margin-top: 2.5px;
  display: inline;
  vertical-align: top;
  position: relative;
}
.steps_title {
  display: inline-block;
  margin-top: 5px;
  margin-bottom: 4px;
  padding-right: 10px;
  font-size: 16px;
  color: #40465a;
  background: #fff;
  word-break: break-all;
  white-space: break-spaces;
  cursor: pointer;
}
.steps_content {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, 0);
  text-align: center;
  padding-top: 8px;
  .title{
    white-space: nowrap;
    font-size: 20px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.65);
    padding-bottom: 4px;
  }
  .time{
    width: 100px;
    font-size: 16px;
    line-height: 24px;
    color: rgba(0, 0, 0, 0.45);
  }
}
.contents_title {
  font-size: 14px;
  color: #40465a;
  display: flex;
  margin-bottom: 5px;
}
.contents_content {
  display: flex;
  margin-bottom: 5px;
}
.steps_status_finish > .steps_tail > i {
  &:after {
    width: 100%;
    @include background_color("colorTheme", 1);
    transition: all 0.2s ease-in-out;
    opacity: 1;
  }
}
.steps_status_finish > .steps_head > .steps_head_inner {
  background-color: #fff;
  @include border_color("colorTheme");
  & i {
    @include font_color("colorTheme");
  }
}
.steps_status_finish,
.steps_status_wait > .steps_main {
  & .steps_title {
    // color: #A1A1A1;
    color: rgba($color: #000000, $alpha: 0.65);
  }
  & .steps_content {
    color: #a1a1a1;
  }
}
.steps_status_finish,
.steps_status_wait > .steps_main {
  & .steps_content {
    color: #a1a1a1;
  }
}
.steps_status_finish,
.steps_status_wait > .steps_head > .steps_head_inner {
  & span {
    color: #ccc;
  }
}
.steps_status_process > .steps_head > .steps_head_inner {
  @include background_color("colorTheme", 1);
  @include border_color("colorTheme");
  color: #ffffff;
}
.steps_status_process > .steps_main > .steps_title {
  font-weight: 500;
  color: rgba($color: #000000, $alpha: 0.85);
}
.steps_vertical {
  display: block;
}
.steps_vertical .steps_item {
  display: block;
  overflow: visible;
}
.steps_vertical .steps_tail {
  position: absolute;
  left: 13px;
  top: 0;
  height: 100%;
  width: 1px;
  padding: 30px 0 4px;
}
.steps_vertical .steps_tail > i {
  height: 100%;
  width: 1px;
}
.steps_vertical .steps_status_finish > .steps_tail > i {
  &:after {
    height: 100%;
  }
}
.steps_vertical .steps_head {
  float: left;
  & .steps_head_inner {
    margin-right: 16px;
  }
}
.steps_vertical .steps_main {
  min-height: 47px;
  overflow: hidden;
  display: block;
}
.steps_vertical .steps_title {
  line-height: 26px;
  margin: 0;
}
.steps_vertical .steps_content {
  padding-bottom: 12px;
  padding-left: 0;
}
</style>
  